package com.example.mvc.controller;

import com.example.mvc.bean.Book;
import com.example.mvc.bean.BookType;
import com.example.mvc.bean.User;
import com.example.mvc.service.BookService;
import com.example.mvc.service.UserService;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;
import java.util.List;

@WebServlet("/getUserList")
public class UserListServlet  extends HttpServlet {
    UserService userService= new UserService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<User> userList = userService.getUserList();
        HttpSession session = req.getSession();
        session.setAttribute("userList",userList);
        String contextPath = req.getContextPath();
        resp.sendRedirect(contextPath+"/admin_user.jsp");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


    }

}
